package com.zareal.ymcc.web.controller;

import com.zareal.ymcc.dto.AlipayNotifyDto;
import com.zareal.ymcc.dto.PayApplyDto;
import com.zareal.ymcc.result.JSONResult;
import com.zareal.ymcc.service.IPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description:
 * @author: Bug修复机
 * @date: 2022年10月17日 ： 14:35
 * @version: ver1.0
 * @email tangli@itsource.cn
 */
@RestController
@RequestMapping("/pay")
public class PayController {

    @Autowired
    private IPayService payService;

    @RequestMapping(value = "/checkPayOrder/{orderNo}",method = RequestMethod.GET)
    public JSONResult checkPayOrder(@PathVariable("orderNo")String orderNo){
        return payService.checkPayOrder(orderNo);
    }
    /**
     * 调用支付宝接口
     **/
    @RequestMapping(value = "/apply",method = RequestMethod.POST)
    public JSONResult apply(@RequestBody PayApplyDto payDto){
        String payResult = payService.apply(payDto);
        return JSONResult.success(payResult);
    }
    /**
     * 支付宝异步回调接口
     * @param alipayNotifyDto
     * @return
     */
    @RequestMapping(value = "/alipay/notify", method = RequestMethod.POST)
    public String alipayNotify(AlipayNotifyDto alipayNotifyDto){
        return payService.alipayNotify(alipayNotifyDto);
    }

}
